#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <time.h>
#include <string.h>
#include <math.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <linux/fb.h>
#include <fcntl.h>
#include <dlfcn.h>
#include "screen.h"
#include "keyboard.h"
#include "box.h"
#include "plugin.h"
#include "codeports.h"

int
main(int argc, char **argv)
{
	int x, y;
	SCR_Init();
	KEY_Init();
	while(!KEY_Update())
	{
		static int f = 0;
		SWP_Clear();
		for(y = 0; y < cp.video.mode.current.yres; y++)
		{
			for(x = 0; x < cp.video.mode.current.xres; x++)
			{
					*(cp.video.swap + y * cp.video.mode.fixed.line_length + x * 4 + 0) = x * 255 / cp.video.mode.current.xres;
					*(cp.video.swap + y * cp.video.mode.fixed.line_length + x * 4 + 1) = f % 255;
					*(cp.video.swap + y * cp.video.mode.fixed.line_length + x * 4 + 2) = x * 255 / cp.video.mode.current.xres;
					*(cp.video.swap + y * cp.video.mode.fixed.line_length + x * 4 + 3) = 0;
			}
		}
		f++;
		SWP_Screen();
	}
	//SCR_Clear();
	KEY_Final();
	SCR_Final();
	return EXIT_SUCCESS;
}
